import java.util.Scanner;

public class sad {
    public static void main(String[] args) {

        int[] leapYear = {0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366};//闰年
        int[] commonYear = {0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365};//平年
        Scanner input = new Scanner(System.in);
        System.out.print("请输入您要查询的年份:");
        int year = input.nextInt();
        System.out.print("请输入您要查询的月份:");
        int month = input.nextInt();
        System.out.print("请输入您要查询的天数：");
        int day = input.nextInt();
        int sumDays = 0;
        if (month > 12 || month < 1) {
            System.out.println("请输入正确的月份!");
        } else {
            //判断是否为闰年
            if ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0) {
                //天数为31天的月份
                if (month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12) {
                    //判断天数是否在31天之内
                    if (day < 1 || day > 31) {
                        System.out.println("请输入正确的天数!");
                    } else {
                        sumDays = leapYear[month - 1] + day;
                    }
                } else if (month == 2) {
                    //判断天数是否在28天之内
                    if (day < 1 || day > 28) {
                        System.out.println("请输入正确的天数!");
                    } else {
                        sumDays = leapYear[month - 1] + day;
                    }
                } else {//为4、6、9、11月中的一月
                    //判断天数是否在30天之内
                    if (day < 1 || day > 30) {
                        System.out.println("请输入正确的天数!");
                    } else {
                        sumDays = leapYear[month - 1] + day;
                    }
                }
            } else {
                //为平年
                //天数为31天的月份
                if (month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12) {
                    //判断天数是否在31天之内
                    if (day < 1 || day > 31) {
                        System.out.println("请输入正确的天数!");
                    } else {
                        sumDays = commonYear[month - 1] + day;
                    }
                } else if (month == 2) {
                    //判断天数是否在29天之内
                    if (day < 1 || day > 29) {
                        System.out.println("请输入正确的天数!");
                    } else {
                        sumDays = commonYear[month - 1] + day;
                    }
                } else {//为4、6、9、11月中的一月
                    //判断天数是否在30天之内
                    if (day < 1 || day > 30) {
                        System.out.println("请输入正确的天数!");
                    } else {
                        sumDays = commonYear[month - 1] + day;
                    }
                }
            }
        }
        System.out.println("这一天为一年中的第" + sumDays + "天");
    }
}
